package test;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static List convertStringToList(String line){
		
		Scanner sc = new Scanner(line);
		List<String> words = new ArrayList<String>();
		while(sc.hasNext()){
			words.add(sc.next());
			
		}
		sc.close();
		return words;
		
	}
public static void remove(List<String> list, String str){
	while (list.indexOf(str) != -1) {
		int loc = list.indexOf(str);
		list.remove(loc);
	}
}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();
	}

}
